# -*- sh -*-
#
# Tests for build-related endpoints
#

# test if default compat build contains labels from base image
TMPD=$(mktemp -d podman-apiv2-test.build.XXXXXXXX)
function cleanBuildTest() {
    podman rmi -a -f
    rm -rf "${TMPD}" &> /dev/null
}
CONTAINERFILE_TAR="${TMPD}/containerfile.tar"
cat > $TMPD/containerfile << EOF
FROM $IMAGE
RUN echo hello
EOF
tar --format=posix -C $TMPD -cvf ${CONTAINERFILE_TAR} containerfile &> /dev/null

t POST "/build?dockerfile=containerfile&t=labeltest" $CONTAINERFILE_TAR 200 \
  '.aux|select(has("ID")).ID~^sha256:[0-9a-f]\{64\}$'

t GET images/labeltest/json 200 \
  .Config.Labels.created_by="test/system/build-testimage"
cleanBuildTest

# vim: filetype=sh
